using ASP;
using HoWave.Web.Shop;
using System;
using System.Text;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Message : Shop, IRequiresSessionState
{
	protected UserControls_cmpy_Top Top1;
	protected TextBox titleBox;
	protected TextBox ContactMenBox;
	protected RadioButtonList RadioButtonList1;
	protected TextBox CompanyNameBox;
	protected TextBox AddressBox;
	protected TextBox TelPhoneBox;
	protected RegularExpressionValidator rex1;
	protected TextBox HomeTelBox;
	protected TextBox FacsimileBox;
	protected TextBox WebsiteBox;
	protected TextBox EmailBox;
	protected TextBox ContentBox;
	protected Button Button1;
	protected UserControls_CMYP_Foot Foot1;
	protected HtmlForm form1;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Init(object sender, EventArgs e)
	{
		try
		{
		}
		catch (Exception ex)
		{
			base.WriteTemErrMsg(ex.Message.ToString());
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
	}
	protected void Button1_Click(object sender, EventArgs e)
	{
		DateTime t = DateTime.Now;
		if (base.Request.Cookies["NowTime"] != null)
		{
			try
			{
				t = DateTime.Parse(base.Request.Cookies["NowTime"].Value);
			}
			catch (Exception)
			{
				t = DateTime.Now;
			}
		}
		if (t > DateTime.Now)
		{
			base.ClientScript.RegisterClientScriptBlock(typeof(Page), "", "<script>alert('在30秒内不能重复提交！')</script>");
		}
		else
		{
			int num = 0;
			base.Response.Cookies["NowTime"].Value = DateTime.Now.ToString();
			string text = this.titleBox.Text;
			if (text.Length > 50)
			{
				base.Response.Write("<script>alert('标题不能超50字！')</script>");
			}
			else
			{
				string text2 = this.ContactMenBox.Text;
				if (text2.Length > 6)
				{
					base.Response.Write("<script>alert('联系人不能超6字！')</script>");
				}
				else
				{
					int num2 = 0;
					try
					{
						num2 = int.Parse(this.RadioButtonList1.SelectedValue);
					}
					catch (Exception)
					{
						num2 = 0;
					}
					string text3 = this.CompanyNameBox.Text;
					if (text3.Length > 100)
					{
						base.Response.Write("<script>alert('公司名称不能过长！')</script>");
					}
					else
					{
						string text4 = this.AddressBox.Text;
						if (text4.Length > 100)
						{
							base.Response.Write("<script>alert('地址名称不能过长！')</script>");
						}
						else
						{
							string text5 = this.TelPhoneBox.Text;
							string text6 = this.HomeTelBox.Text;
							string text7 = this.FacsimileBox.Text;
							string text8 = this.WebsiteBox.Text;
							if (text8.Length > 100)
							{
								base.Response.Write("<script>alert('网址不能过长！')</script>");
							}
							else
							{
								string text9 = this.EmailBox.Text;
								string text10 = this.ContentBox.Text;
								if (text10.Length > 500)
								{
									base.Response.Write("<script>alert('内容不能超500字！')</script>");
								}
								else
								{
									StringBuilder stringBuilder = new StringBuilder();
									stringBuilder.Append("insert into HLMall_Message(Title,ContactMen,Sex,CompanyName,Address,TelPhone,HomeTel,Facsimile,Website,Email,CreateTime,[Content])");
									stringBuilder.Append(string.Concat(new object[]
									{
										" values('",
										text,
										"','",
										text2,
										"',",
										num2,
										",'",
										text3,
										"','",
										text4,
										"','",
										text5,
										"',"
									}));
									stringBuilder.Append(string.Concat(new string[]
									{
										"'",
										text6,
										"','",
										text7,
										"','",
										text8,
										"','",
										text9,
										"','",
										DateTime.Now.ToString(),
										"','",
										text10,
										"')"
									}));
									try
									{
										num = this.conn.Execute(stringBuilder.ToString());
									}
									catch (Exception)
									{
										num = 0;
									}
									if (num > 0)
									{
										base.ClientScript.RegisterClientScriptBlock(typeof(Page), "", "<script>alert('提交成功！')</script>");
										base.Response.Cookies["NowTime"].Value = DateTime.Now.AddSeconds(30.0).ToString();
									}
								}
							}
						}
					}
				}
			}
		}
	}
}
